package com.nwpu.pojo;

/**
 * Message
 *
 * @author 龙虹宇
 * @version 1.0
 * @date 2023/11/24
 */
public class Message {
    // id自增计数
    private static int idCount = 0;
    private int id;
    private String username;
    private String receiverName;
    private String time;
    private String messageText;

    /**
     * Instantiates a new Message.
     *
     * @param username      the username
     * @param receiverName the other username
     * @param time          the time
     * @param messageText   the messageText
     */
    public Message(String username, String receiverName, String time, String messageText) {
        this.username = username;
        this.receiverName = receiverName;
        this.time = time;
        this.messageText = messageText;
        // id自增
        this.id = ++idCount;
    }

    /**
     * Gets id.
     *
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * Sets id.
     *
     * @param id the id
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * Gets username.
     *
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * Sets username.
     *
     * @param username the username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Gets other username.
     *
     * @return the other username
     */
    public String getReceiverName() {
        return receiverName;
    }

    /**
     * Sets other username.
     *
     * @param receiverName the other username
     */
    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }

    /**
     * Gets time.
     *
     * @return the time
     */
    public String getTime() {
        return time;
    }

    /**
     * Sets time.
     *
     * @param time the time
     */
    public void setTime(String time) {
        this.time = time;
    }

    /**
     * Gets message text.
     *
     * @return the message text
     */
    public String getMessageText() {
        return messageText;
    }

    /**
     * Sets message text.
     *
     * @param messageText the message text
     */
    public void setMessageText(String messageText) {
        this.messageText = messageText;
    }

    @Override
    public String toString() {
        return "Message{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", receiverName='" + receiverName + '\'' +
                ", time='" + time + '\'' +
                ", messageText='" + messageText + '\'' +
                '}';
    }
}
